<template>
  <el-dialog
    v-model="dialogVisible"
    title="查询模具档案"
    width="900px"
    @close="closeDialog"
  >
    <el-form label-width="120px" :model="state.queryForm">
      <el-row :gutter="12">
        <el-col :span="12">
          <el-form-item label="模具编码">
            <el-input
              v-model="state.queryForm.moldCode"
              placeholder="请填写编码"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="模具名称">
            <el-input
              v-model="state.queryForm.moldName"
              placeholder="模具名称"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="模具型号/项目">
            <el-input v-model="state.queryForm.moldSpec" placeholder="项目" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <template #footer>
      <span class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="toQuery">查询</el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script setup>
  import { localStorageConfig } from '@/config/localstorage.config'

  const pkCorp = localStorage.getItem(localStorageConfig.__pkCorp)
  const dialogVisible = ref(false)
  const state = reactive({
    queryForm: {
      state: 1,
      pkCorp: pkCorp,
    },
  })

  const openDialog = () => {
    dialogVisible.value = true
  }

  const toQuery = () => {
    _emit('success-callback', state.queryForm)
    dialogVisible.value = false
  }

  defineExpose({
    openDialog,
  })
  const _emit = defineEmits(['success-callback'])
</script>
